package com.molichuxing.services.infrastructure.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.framework.utils.ObjectCastUtil;
import com.molichuxing.services.infrastructure.bean.GztThreeverifyNotifyLogBean;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.GztThreeverifyNotifyLogMapper;
import com.molichuxing.services.infrastructure.dto.request.create.GztThreeverifyNotifyLogCreateDto;
import com.molichuxing.services.infrastructure.dto.response.GztThreeverifyNotifyLogDto;
import com.molichuxing.services.infrastructure.service.GztThreeverifyNotifyLogService;
/**
 * 
 * @author liyg
 * 国政通三要素服务实现类
 * 2019-09-23
 *
 */
@Service("gztThreeverifyNotifyLogService")
public class GztThreeverifyNotifyLogServiceImpl implements GztThreeverifyNotifyLogService{

	@Autowired
	private GztThreeverifyNotifyLogMapper gztThreeverifyNotifyLogMapper;
	
	/**
	 * 保存
	 * @param createDto
	 * @return
	 */
	@Override
	public Integer create(GztThreeverifyNotifyLogCreateDto createDto) {
		GztThreeverifyNotifyLogBean bean=new GztThreeverifyNotifyLogBean();
		BeanUtils.copyProperties(createDto, bean);
		gztThreeverifyNotifyLogMapper.create(bean);
		return bean.getId();
	}
	
	/**
	 * 获取国政通三要素验证日志
	 * 
	 * @param map
	 *            参数
	 *key:idNumber
	 *            String 身份证号 非必填
	 *key:realName
	 *            String 用户真实姓名 非必填
	 *key:userPhone
	 *            String 用户手机号 非必填
	 *key:startTime
	 *            String 请求开始时间 非必填
	 *key:endTime
	 *            String 请求结束时间 非必填
	 *key:pageNum
	 *            Integer 当前页
	 *key:pageSize
	 *            Integer 每页显示条数
	 * @return
	 */
	@Override
	public Paged<GztThreeverifyNotifyLogDto> getGztThreeverifyNotifyLogList(Map<String, Object> map) {
		// 查询总条数
		long total = gztThreeverifyNotifyLogMapper.getGztThreeverifyNotifyLogListCount(map);
		if(total <= 0) {
			return null;
		}
		
		/*分页查询集合*/ 
		Integer pageNum = ObjectCastUtil.castInteger(map.get("pageNum"));
		Integer pageSize = ObjectCastUtil.castInteger(map.get("pageSize"));       
		List<GztThreeverifyNotifyLogBean>  list =  gztThreeverifyNotifyLogMapper.getGztThreeverifyNotifyLogList(map,pageNum,pageSize);
		List<GztThreeverifyNotifyLogDto> dtoList = Convert.GztThreeverifyNotifyLogDto(list);
		Paged<GztThreeverifyNotifyLogDto> paged = new Paged<>(dtoList, total,pageSize);
		return paged;
	}
}
